using Orchard.ContentManagement;
using Orchard.Core.Routable.Models;
using System.Collections.Generic;

namespace Dyn.News.Models
{
    public class NewsCategoryPart : ContentPart<NewsCategoryPartRecord>
    {
        public string Name
        {
            get { return this.As<RoutePart>().Title; }
            set { this.As<RoutePart>().Title = value; }
        }
        public string Url
        {
            get { return this.As<RoutePart>().Path; }
            set { this.As<RoutePart>().Path = value; }
        }
        public string Description
        {
            get { return Record.Description; }
            set { Record.Description = value; }
        }

        public int PostCount
        {
            get { return Record.PostCount; }
            set { Record.PostCount = value; }
        }
        public int ParentID
        {
            get { try { return Record.ParentID; } catch { return 0; } }
            set { try { Record.ParentID = value; } catch { Record.ParentID = 0; } }
        }
        public int OrderDisplay 
        {
            get { return Record.OrderDisplay; }
            set { Record.OrderDisplay = value; }
        }
        public IEnumerable<NewsCategoryPart> Categories { get ; set; }
        public IEnumerable<NewsCategoryPart> CategoryParents { get; set; }
        public IEnumerable<NewsCategoryPart> CategoryChilds { get; set; }
    }
}